package com.glb.app.controller;

import com.glb.app.assistant.XiaoZhiAgent;
import com.glb.app.bean.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@Tag(name = "小智", description = "小智")
@RestController
@RequestMapping("/xiaozhi")
public class XiaoZhiController {


    @Autowired
    private XiaoZhiAgent xiaoZhiAgent;

    @Operation(summary = "对话")
    @RequestMapping(value = "/chat",produces = "text/stream;charset=UTF-8")
    public Flux<String> getAnswer(@RequestBody ChatForm question) {
        return xiaoZhiAgent.chat(question.getMemoryId(), question.getMessage());
    }

}
